package com.huawei.appmarket.oobe.app;

import android.app.job.JobInfo.Builder;
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
import android.app.job.JobService;
import android.content.ComponentName;
import android.content.Context;
import android.os.Build.VERSION;
import android.telephony.TelephonyManager;
import androidx.annotation.RequiresApi;
import com.huawei.hwid.core.constants.HwAccountConstants;
import o.dli;
import o.Logger;

@RequiresApi(api = 21)
public class OOBEAppListUpdateCheckJobService extends JobService {
    public static void schedule(Context context) {
        if (VERSION.SDK_INT >= 26) {
            ((JobScheduler) context.getSystemService("jobscheduler")).schedule(new Builder(1005, new ComponentName(context.getPackageName(), OOBEAppListUpdateCheckJobService.class.getName())).setPersisted(true).setMinimumLatency(HwAccountConstants.CHECK_SITE_COUNTRY_DURATION * ((long) dli.ˊ(context).getInt("appListCheckIntervalTime", 14))).setRequiredNetworkType(1).build());
            Logger.ˎ("OOBE", "OOBEAppListUpdateCheckJobService scheduled");
        }
    }

    public boolean onStartJob(JobParameters jobParameters) {
        Logger.ˎ("OOBE", "OOBEAppListUpdateCheckJobService onStartJob");
        schedule(this);
        if (dli.ˋ(this) == 2) {
            dli.ˎ(this);
        } else {
            boolean z;
            if (dli.ˋ()) {
                z = true;
            } else {
                z = dli.ˏॱ(this);
            }
            if (z) {
                boolean ᐝ = dli.ᐝ(this);
                if (((TelephonyManager) getSystemService("phone")).getSimState() == 5) {
                    z = true;
                } else {
                    z = false;
                }
                if (ᐝ || r0) {
                    if (dli.ˊॱ(this)) {
                        Logger.ˎ("OOBE", "OOBEAppListUpdateCheckJobService skipped as notification showing");
                    } else {
                        OOBEQueryIfSupportJobService.schedule(this, 3, false);
                    }
                }
            }
        }
        return false;
    }

    public boolean onStopJob(JobParameters jobParameters) {
        return true;
    }
}
